﻿<%@ Page Language="C#" Title ="添加好友" AutoEventWireup="true" CodeBehind="adduserfriend.aspx.cs" Inherits="chatblog.usercate.dialog.adduserfriend" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

<%--添加好友--%>
        <div class="sample_popup" id="popup" style=" position:absolute ; height:250px; width :350px; z-index :2;  display :block; ">                    
            <div class="menu_form_body">    
                <div style =" width :100%;">
                    <table >
                        <tr>
                            <td  style =" width :200px; ">
                                <span style =" text-align :left ">您好友的Email：</span>
                            </td>
                            <td>  
                                <input id="NewUserText" type="text" style="width: 200px" />
                            </td>
                        </tr>                        
                        <tr>
                            <td >
                                <span style =" text-align :left ">您好友的昵 称：</span>
                            </td>
                            <td>
                                <input id="UserNickText" type="text" style="width: 200px" />
                            </td>
                        </tr>
                    </table>                              
                </div>
                <div id="GroupListDiv"  >
                </div>
                <div style="text-align: center;  width: 100%">
                    <input id="AddButton" type="button" value="增加" onclick=" addUser();" />
                    <input id="CancelButton" type="button" value="取消" onclick="window.close();" />
                </div>
                <%-- <input id="GroupIdHidden" type="hidden"  />--%>
            </div>
        </div>  
    <script src="common.js" type="text/javascript"></script>
    <script type ="text/javascript" >
        
        function windowonload() {
            //alert(window.location.search);
            if (window.location.search == "") {
                alert("对不起，没有相应的参数！");
                closeWithNoTip();
            }
            else {
                var groupid = getQueryString("Groupid");
                paramsAllready = true;
                document.getElementById("GroupListDiv").innerHTML = chatblog.usercate.chRoom.GetGroupListSelectHtml(groupid).value;
            }
        }
        window.onload = windowonload;
        //添加好友
        function addUser() {
            if (paramsAllready == false || window.opener == null)
                return;
                
            var groupselect = document.getElementById('GroupListSelect');
            var usertextbox = document.getElementById('NewUserText');
            var isemail = verifyAddress(usertextbox.value);
            if (!isemail) {
                alert("对不起,您输入好友的Email：" + usertextbox.value + " 格式不正确,请重新输入!");
                //                        maskBody(50, 'maskDiv');
                return false;
            }
            var nicktextBox = document.getElementById('UserNickText');
            if (nicktextBox.value.replace(/\s/g, "") == "") {
                alert('对不起，好友昵称不能为空或空格,请重新输入！');
                return false;
            }
            var selectedIndex = groupselect.selectedIndex;
            var result = chatblog.usercate.chRoom.AddGroupUser(groupselect[selectedIndex].id, usertextbox.value, nicktextBox.value, "");
            if (result.value == "") {
                usertextbox.value = "";
                nicktextBox.value = "";
                window.opener.RefreshGroupDiv();
                window.close();
                return true;
            }
            else {
                alert(result.value);
            }
            return false;

        }

        
    </script>
    </form>
</body>
</html>
